/*
* @author : TF-BJ-C064
* @creation : 2014-6-27 下午4:30:37
* @description : 
*
*/

package com.action.park;
import java.util.List;
import org.apache.log4j.Logger;
import com.base.UserBean;
import com.bean.ParkOrder;
import com.dao.ParkOrderDao;
import com.service.ParkOrderService;
import com.util.GUtil;

public class ParkOrderAction extends BaseParkAction{

	 private static final Logger log = Logger.getLogger(ParkOrderDao.class);
	 
	ParkOrderService parkOrderService;
	ParkOrder parkOrder;
	List<ParkOrder> list;
	
	Boolean queryMyOrder=true;//true: 收费员查询自己的订单 ; false查询所有订单
	
	@Override
	public String handle() throws Exception {
		if(id==null)
			return this.query();
		else
			return this.view();
	}
	
	/**
	 * 订单管理
	 * <p>Title: query</p>
	 * <p>Description: 
	 * 		首先根据session中user.role 判断是停车场管理员还是后台管理员
	 * 		if(user.role==3)// 停车场管理员
	 * 		else if(user.role==1) //停车场收费员
	 * 		else if(user.role>UserBean.MAX_PARK_ROLE_ID)//后台管理员
	 * </p>
	 * @return
	 * @throws Exception
	 * @see com.action.park.BaseParkAction#query()
	 */
	
	@Override
	public String query() throws Exception {
		this.setHeaderTitle("订单查询");
		if(user.getRole()==3){
			// 停车场管理员  
			//查看本停车场所有的订单
			list  = parkOrderService.queryMyParkOrder(parkOrder, user,page);
			if(list==null){
				log.info("停车场管理员"+user.getUserCode()+" - "+user.getUserName()+"  查看本停车场所有的订单 list==null");
			}else{
				log.info("停车场管理员"+user.getUserCode()+" - "+user.getUserName()+"  查看本停车场所有的订单 list.size= "+list.size());
			}
		}else if(user.getRole()==1){
			//停车场收费员
			if(queryMyOrder){//只查看我的订单
				list  = parkOrderService.queryMyOrder(parkOrder, user,page);
			}
		}else if(user.getRole()>UserBean.MAX_PARK_ROLE_ID){
			//后台管理员
			list = parkOrderService.query(parkOrder, user,page);//查看所有订单
		}
		return GUtil.SUCCESS;
	}

	@Override
	public String delete() throws Exception {
		return null;
	}

	@Override
	public String view() throws Exception {
		return null;
	}

	@Override
	public String add() throws Exception {
		return null;
	}

	@Override
	public String update() throws Exception {
		return null;
	}

	/**
	 * @return the parkOrderService
	 */
	public ParkOrderService getParkOrderService() {
		return parkOrderService;
	}
	/**
	 * @param parkOrderService the parkOrderService to set
	 */
	public void setParkOrderService(ParkOrderService parkOrderService) {
		this.parkOrderService = parkOrderService;
	}

	/**
	 * @return the parkOrder
	 */
	public ParkOrder getParkOrder() {
		return parkOrder;
	}

	/**
	 * @param parkOrder the parkOrder to set
	 */
	public void setParkOrder(ParkOrder parkOrder) {
		this.parkOrder = parkOrder;
	}

	/**
	 * @return the list
	 */
	public List<ParkOrder> getList() {
		return list;
	}

	/**
	 * @param list the list to set
	 */
	public void setList(List<ParkOrder> list) {
		this.list = list;
	}

	/**
	 * @return the queryMyOrder
	 */
	public Boolean getQueryMyOrder() {
		return queryMyOrder;
	}

	/**
	 * @param queryMyOrder the queryMyOrder to set
	 */
	public void setQueryMyOrder(Boolean queryMyOrder) {
		this.queryMyOrder = queryMyOrder;
	}

	@Override
	public boolean validate(Object obj) throws Exception {
		return false;
	}
}
